/**
 * Creat with IntelliJ IDEA
 * Description:
 * User:WZW
 * Date:2022-02-27
 * Time:15:41
 */
public class HashBuck {

    public int firstUniqChar(String s) {
        if (s == null) return 0;
        int[] hash = new int['z'-'a'];
        for (int i = 0; i < s.length(); i++) {
            hash[s.charAt(i)-'a']++;
        }
        for (int i = 0; i < s.length(); i++) {
            if (hash[s.charAt(i)-'a']==1) return i;
        }
        return -1;
    }
}
